public class ReadLine {
    private final String content;
    private int index;

    public ReadLine(String str) {
        this.content = str;
        this.index = 0;
    }

    public String readLine() {
        int length = 0;
        String line;

        if (this.index >= this.content.length() - 1) {
            return null;
        }

        for (int i = this.index; i < this.content.length(); ++i) {
            if (this.content.charAt(i) == '\n') {
                break;
            }
            length += 1;
        }

        line = this.content.substring(this.index, this.index + length);
        this.index += length + 1;
        return line;
    }
}
